#!/bin/bash
#lua version >= 5.3
#lua_exe=lua
clear
lua_exe=../depends/skynet1.5.0/3rd/lua/lua

dirs=("../src/common" "../src/config" "../src/ndgame" "../src/ndadmin" "../src/ndtest" )

_read_globals=" --read-globals table.tostring _G _ENV g"
_globals=" --globals table.tostring SERVICE_NAME class table bit_set bit_test checknumber checkbool checktable checkint math printf\
			 isset require os pcall xpcall string bit32 new handler sys_tostring tostring"
_ignore=" --ignore 211 212 213 231 411 412 421 422 431 512 611 612 613 614 _tostring g"
_max_line_len=" --max-line-length 250"
#_exclude_field=" --exclude-files ../src/common/utils/functions.lua"
_exclude_field=" "
luacheck_opt=$_ignore""$_read_global""$_globals""$_exclude_field""$_max_line_len" -q --std lua53 --no-cache --no-self "
echo $luacheck_opt
for dir in ${dirs[*]}; do
    find $dir -name "*.lua" |xargs $lua_exe luacheck/main.lua $luacheck_opt
done

## References
# https://luacheck.readthedocs.io/en/stable/cli.html
# https://luacheck.readthedocs.io/en/stable/warnings.html